import 'package:flutter/material.dart';
import 'package:my_flutter_github/MyStyle.dart';

///用户头像
class UserIconWidget extends StatelessWidget {
  final String image;
  final VoidCallback onPressed;
  final double width;
  final double height;
  final EdgeInsetsGeometry padding;

  const UserIconWidget(
      {Key key,
      this.image,
      this.onPressed,
      this.width = 30.0,
      this.height = 30.0,
      this.padding})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return RawMaterialButton(
        materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
        padding: padding ?? EdgeInsets.only(left: 5.0, top: 4.0, right: 5.0),
        constraints: BoxConstraints(minWidth: 0.0, minHeight: 0.0),
        child: ClipOval(
          child: FadeInImage.assetNetwork(
            placeholder: MyIcons.DEFAULT_USER_ICON,
            fit: BoxFit.fitWidth,
            image: image,
            width: width,
            height: height,
          ),
        ),
        onPressed: onPressed);
  }
}
